﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SchoolManagementSystem
{
    public partial class DateTimeUserControl : UserControl
    {
        private delegate void DisplayTime();

        public System.Timers.Timer displayTimer = new System.Timers.Timer();

        public DateTimeUserControl()
        {
            InitializeComponent();
        }

        public void DisplayTimeEvent(object source, System.Timers.ElapsedEventArgs e)
        {
            DisplayTime disp = new DisplayTime(ShowCurrentTime);
            this.BeginInvoke(disp);
        }

        private void ShowCurrentTime()
        {
            lblDisplayDate.Text = DateTime.Now.ToString();
        }

        private void DateTimeUserControl_Load(object sender, EventArgs e)
        {
            displayTimer.Elapsed += new System.Timers.ElapsedEventHandler(DisplayTimeEvent);
            displayTimer.Interval = 1000;
            displayTimer.Start();
            ShowCurrentTime();
        }

        private void lblDisplayDate_Click(object sender, EventArgs e)
        {

        }
    }
}
